using System;
using System.Collections.Generic;
using System.Windows.Media.Media3D;

namespace Sensor.UI.Models;
/// <summary>
/// 点云信息
/// </summary>
public class PointCloudInfo
{
    public PointCloudCameraInfo CameraInfo { get; set; } = null!;
    /// <summary>
    /// 分布区域集合
    /// </summary>
    public List<PointCloudRegionInfo> RegionInfos { get; set; } = [];

    /// <summary>
    /// 区域点集合
    /// </summary>
    public List<PointCloudItemInfo> ItemInfos { get; set; } = [];

    /// <summary>
    /// 存储所有点用于网格生成
    /// </summary>
    public List<Point3D> AllPoints { get; set; } = new List<Point3D>(); 
    /// <summary>
    /// 存储点的索引矩阵
    /// </summary>
    public int[,]? PointIndices { get; set; }

    /// <summary>
    /// 线框点集合
    /// </summary>
    public List<Point3D> WireframePoints { get; set; } = [];
}

/// <summary>
/// 相机
/// </summary>
public class PointCloudCameraInfo
{
    /// <summary>
    /// Position
    /// </summary>
    public Point3D Position { get; set; }

    /// <summary>
    /// LookDirection
    /// </summary>
    public Vector3D LookDirection { get; set; }

    /// <summary>
    /// UpDirection
    /// </summary>
    public Vector3D UpDirection { get; set; }
}

/// <summary>
/// 点云点信息 
/// </summary>
public class PointCloudItemInfo
{
    /// <summary>
    /// 点坐标
    /// </summary>
    public Point3D Point { get; set; }

    /// <summary>
    /// 法向量
    /// </summary>
    public Vector3D Vector { get; set; }
}

/// <summary>
/// 点云区域信息
/// </summary>
public class PointCloudRegionInfo
{
    /// <summary>
    /// 区域索引
    /// </summary>
    public int Index { get; set; }

    /// <summary>
    /// 区域中心点
    /// </summary>
    public PointCloudItemInfo RegionPoint { get; set; }=null!;

    /// <summary>
    /// 区域内的点云点集合
    /// </summary>
    public List<PointCloudRegionItemInfo> ItemInfos { get; set; } = [];

    /// <summary>
    /// 获取区域中心点坐标
    /// </summary>
    public Point3D CenterPoint => RegionPoint.Point;

    /// <summary>
    /// 获取或设置距离阈值
    /// </summary>
    public double DistanceThreshold { get; set; } = 1.0;
}

/// <summary>
/// 点云区域信息 
/// </summary>
public class PointCloudRegionItemInfo
{
    /// <summary>
    /// 点坐标
    /// </summary>
    public Point3D Point { get; set; }

    /// <summary>
    /// 法向量
    /// </summary>
    public Vector3D Vector { get; set; }

    /// <summary>
    /// 距离
    /// </summary>

    public double Distance { get; set; }
}